﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 9/4/2009
 * Time: 9:35 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using NHibernate;
using System.Collections.Generic;
using System.Data;
using PilotFish.Model.Dao.Interface;

namespace PilotFish.Model.Dao.NHibernate
{
	/// <summary>
	/// Description of NHibernateClinicDao.
	/// </summary>
	public class NHibernateClinicDao : IClinicDao
	{
		public NHibernateClinicDao()
		{
		}
		
		public void SaveOrUpdate(Clinic clinic)
		{
			ISession session = NHibernateHelper.OpenSession();
			session.SaveOrUpdate(clinic);
			session.Flush();
		}
		
		public void Delete(Clinic clinic)
		{
			ISession session = NHibernateHelper.OpenSession();
			session.Delete(clinic);
			session.Flush();
		}
		
		public Clinic ReadByPk(int id)
		{
			return NHibernateHelper.OpenSession().Load<Clinic>(id);
		}
		
		public IList<Clinic> FindAll()
		{
			return NHibernateHelper.OpenSession().CreateCriteria(typeof(Clinic)).List<Clinic>();
		}
	}
}
